package cn.fanxin.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: china-fanxin
 * @Website: https://fan-xin.cn
 * @Description: 定义指标公式支持的计算类型枚举类
 * @Date: 2022/11/24 14:31
 * @Param:
 * @return:
 */
public enum JsTypeEnum {

    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description: 时间移动
     * @Date: 2022/11/24 14:47
     */
    NOR("NOR"),
    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description: 时间范围的累计
     * @Date: 2022/11/24 16:33
     */
    SUM("SUM"),
    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description: 时间范围内的平均值计算
     * @Date: 2022/11/24 14:47
     */
    AVG("AVG"),
    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description: 时间范围内的净增值计算
     * @Date: 2022/11/24 14:47
     */
    NIO("NIO"),
    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description:
     * @Date: 2022/11/24 14:47
     */
    VD("VD"),
    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description:
     * @Date: 2022/11/24 14:47
     */
    VDL("VDL");

    JsTypeEnum(String value){
        this.value = value;
    }

    private String value;


    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description: 返回支持的计算类型集合
     * @Date: 2022/11/25 10:29
     * @Param: []
     * @return: java.util.List<java.lang.String>
     */
    public static List<String> toList(){
        List<String> resList = new ArrayList<>();
        for (JsTypeEnum values:JsTypeEnum.values()){
            resList.add(values.getValue());
        }
        return resList;
    }

    /**
     * @Author: china-fanxin
     * @Website: https://fan-xin.cn
     * @Description: 枚举值转为逗号分隔的字符串
     * @Date: 2022/11/24 15:10
     * @Param: []
     * @return: java.lang.String
     */
    public static String toDefString() {
        String res ="";
        for (JsTypeEnum value:JsTypeEnum.values()){
            res = res +value.getValue()+",";
        }
        res = res.substring(0,res.length()-1);
        return res;
    }
}
